$.getJSON('/index.php/Lecture/Tool/getJssdk?url='+encodeURIComponent(location.href),function(rst){
  wx.config({
    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
    appId: rst.appId, // 必填，公众号的唯一标识
    timestamp: rst.timestamp, // 必填，生成签名的时间戳
    nonceStr: rst.nonceStr, // 必填，生成签名的随机串
    signature: rst.signature,// 必填，签名，
    jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline',
        "startRecord","stopRecord","onVoiceRecordEnd","uploadVoice","playVoice","stopVoice","onVoicePlayEnd",
        "hideMenuItems","hideAllNonBaseMenuItem"] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2 //,
  });
  wx.ready(function(){
    // wx.hideMenuItems({ menuList: ["menuItem:openWithQQBrowser", "menuItem:openWithSafari"] });
    // wx.hideAllNonBaseMenuItem();
  });
});

app.getParam=function(a){var b=location.search;a=a+"=";return b.indexOf(a)==-1?'':b.substring(b.indexOf(a)+a.length,b.indexOf("&",b.indexOf(a))==-1?b.length:b.indexOf("&",b.indexOf(a)))};


app.sign = app.getParam('sign');
$("#xesOLPeople").text(app.getParam('num'));
document.title = '家长成长学院直播间';

app.host = 'http://uc.gzxueersi.com/index.php';
if(location.href.indexOf('/topic')>-1){
  app.host = '';
  app.sign = 'localdevelopmentsign';
}
app.host += '/lecture';
// app.resPath = '../view/dist/';


app.dynamicLoadingCss=function(h,i){var j=document.createElement("link");var f=document.getElementsByTagName("head")[0];j.href=h;j.rel="stylesheet";j.type="text/css";if(typeof i==="function"){var g;j.onload=j.onreadystatechange=function(){if(!g&&(!j.readyState||/loaded|complete/.test(j.readyState))){j.onload=j.onreadystatechange=null;g=true;i()}}}f.appendChild(j)};

app.getTime = function(t, f){
  var e=new Date(parseInt(t)),y=e.getFullYear(),m=e.getMonth()+1,d=e.getDate(),h=e.getHours(),i=e.getMinutes(),s=e.getSeconds();
  m=m>9?m:'0'+m; d=d>9?d:'0'+d; h=h>9?h:'0'+h; i=i>9?i:'0'+i; s=s>9?s:'0'+s;
  return y+'-'+m+'-'+d+' '+h+':'+i+(f==1?':'+s:'');
};


app.dynamicLoadingJs("https://unpkg.com/alloylever@1.0.1/alloy-lever.js", function(){
  AlloyLever.config({
      cdn:'//s.url.cn/qqun/qun/qqweb/m/qun/confession/js/vconsole.min.js',  //vconsole CDN address
      reportUrl: "//a.qq.com",  //Error reporting address
      reportPrefix: 'qun',    //An error reporting msg prefix is generally used to differentiate business types
      reportKey: 'msg',        //Error reporting msg prefix key, user reporting system receives storage msg
      otherReport: {              //Other information to be reported
          uin: 491862102
      },
      entry:".qlStartDate"          //Please click on this DOM element to summon vConsole 6 times. You can use AlloyLever.entry('#entry2') add more entry
  });
});

$.getJSON(app.host + '/Lecture/getCourseInfo?sign='+app.sign,function(rst){
  if(rst.error){
    alert(rst.errMsg);
    history.back();
  }else {
    app.info = rst.info;
    // document.title = app.info.name;
    document.title = '家长成长学院直播间';
    $(".ql_start_box .name").text(app.info.name);
    $(".qlStartDate ").text('本次直播于'+app.info.start_time+'开始');
    // 手动更新缓存
    app.info.bust = '34';

    $.getJSON(app.host + '/Listener/liveBaseinfo?sign='+app.sign,function(rst2){
      app.user = rst2;
    });
    $.getJSON(app.host + '/Message/list_z?sign='+app.sign,function(rst3){
        app.list = rst3;
        app.dynamicLoadingJs(app.resPath+'js/topic/xesCommon.js?bust='+app.info.bust, function(){
          app.dynamicLoadingJs(app.resPath+'js/topic/topic.js?bust='+app.info.bust);
          app.dynamicLoadingJs(app.resPath+'js/topic/exif.js?bust='+app.info.bust);
          // app.dynamicLoadingJs(app.resPath+'js/topic/xueersiLive.js?bust='+app.info.bust);
        });
        app.dynamicLoadingCss(app.resPath+'css/topic/topic.css?bust='+app.info.bust, function(){
          $(".ppt-select-layer, .caozuo_box").attr('style', ''); // 去掉隐藏的 css 代码
          $(".flex-body").show();
          $(".xesLoading").hide();
        });

    });
  }

});
